<?php
namespace Admin\Models\ims;
use Admin\Models\BaseModel;
class XHImsReturnTab extends BaseModel
{

    /**
     *
     * @var integer
     * @Primary
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iRTId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iSource;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sSourceIds;


    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iState;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $mDesc;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $mData;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $mSourceName;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     * create by dale 20181205
     */
    public $iSchoolId;

    /**
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     * create by dale 20181205
     */
    public $iBPPId;



    /**
     * Initialize method for model.
     */
//    public function initialize()
//    {
//        $this->setSource("XHLm_Receive");
//    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHIms_ReturnTab';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHImsReturnTab[]|XHImsReturnTab|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHImsReturnTab|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }


    public function afterFetch()
    {
        $this->mData = $this->mData ? unserialize($this->mData) : [];
        return true;
    }

    public function save($data = null, $whiteList = null, $recordUpdateInfo = true)
    {
        if ($recordUpdateInfo) {
            parent::beforeUpdate();
        } else {
            $this->beforeUpdate();
        }
        return parent::save($data, $whiteList);
    }

    public function beforeUpdate()
    {
        return true;
    }

    public function beforeSave()
    {
        $this->mData = serialize($this->mData);
        return true;
    }


}
